package com.qiaoba.common.base.context;

/**
 * 用户信息上下文
 *
 * @author ailanyin
 * @date 2023-09-10 19:40:39
 */
public class UserInfoContext {

    private static ThreadLocal<String> USER_ID = new ThreadLocal<>();
    private static ThreadLocal<String> USER_NAME = new ThreadLocal<>();
    private static ThreadLocal<String> DEVICE_SN = new ThreadLocal<>();
    private static ThreadLocal<String> NICKNAME = new ThreadLocal<>();

    public static String getUserId() {
        return USER_ID.get();
    }

    public static void setUserId(String userId) {
        USER_ID.set(userId);
    }

    public static String getUsername() {
        return USER_NAME.get();
    }

    public static void setUsername(String username) {
        USER_NAME.set(username);
    }

    public static String getDeviceSn() {
        return DEVICE_SN.get();
    }

    public static void setDeviceSn(String deviceSn) {
        DEVICE_SN.set(deviceSn);
    }

    public static String getNickname() {
        return NICKNAME.get();
    }

    public static void setNickname(String nickname) {
        NICKNAME.set(nickname);
    }

    public static void clear() {
        USER_ID.remove();
        USER_NAME.remove();
        DEVICE_SN.remove();
        NICKNAME.remove();
    }
}
